///////////////////////////////////////////////////////////
//
// File: HaptHIDDevice.h
//
// Description: Generice interface for conecting to standard
//              HID devices.
//
///////////////////////////////////////////////////////////

#ifndef _HAPT_HIDDEVICE_H_
#define _HAPT_HIDDEVICE_H_

// Local Includes
#include "HaptCtrlDecl.h"

// System Includes
#include <wtypes.h>
#include <initguid.h>
#include <process.h>
#include <string>
#include <vector>

using namespace std;

// NOTE: All Windows DDK headers must be included inside of extern  
//       "C" blocks in order to correctly link against the library
extern "C" {
    // Windows DDK Includes
    #include <hidsdi.h>
    #include <setupapi.h>
}


class HaptHIDDevice 
{
  public:
    HaptHIDDevice();
    ~HaptHIDDevice();

    int  id() { return _uniqID; }
    
    bool wait( unsigned int time=300 );
    bool disconnect();

    static bool queryDeviceCapabilities( HaptHIDDevice &device );
    static bool outputToDevice( HaptHIDDevice &device, byte* pBuff, DWORD &oBytes );
    static bool connectToDevices( int vendor, int product, vector<HaptHIDDevice> &ovDev );

    DWORD queryEvent( unsigned char aChar[], DWORD &oBytes );

  protected:
    // Capability Structure
    HIDP_CAPS  _hidCap;
    
    // Handles
    HANDLE     _hDevice;
    HANDLE     _hEvent;

    // File Structures
    OVERLAPPED _overlap;

    // Device Path
    string     _devicePath; 

    // Unique ID
    int        _uniqID;
};

#endif // _HAPT_HIDDEVICE_H_